//
//  ViewController.m
//  Attention
//
//  Created by student on 16/2/18.
//  Copyright © 2016年 NIIT. All rights reserved.
//

#import "ViewController.h"
//练习
//1. 分析整个应用中总共有多少那些对象？罗列出来
//UIAlertView对象(3个)
//AppDelegate对象
//UIWindow对象


//Button（4个）
//Label (1个)
//UIActionSheet(1个)
//UIView对象（1个）
//VIE我Controller（1个）


//2. 使用Reveal查看程序结构
//3. 使用纯代码实现本程序





@interface ViewController ()<UIAccelerometerDelegate>

@property (weak, nonatomic) IBOutlet UILabel *infoLabel;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


- (IBAction)bth1pressed:(UIButton *)sender
{
    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"弹出框"
                              //框的标题
                                                        message:@"呵呵"
                              //弹出框里面的信息
                                                       delegate:self cancelButtonTitle:@"确认"//按钮上的文字
                                              otherButtonTitles: nil];
    [alertView show];
}


- (IBAction)bth2pressed:(UIButton *)sender
{
    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"弹出窗口2" message:@"中饭吃了没？" delegate:self cancelButtonTitle:@"吃了" otherButtonTitles:@"正在吃",@"还没吃", nil];
    [alertView show];
    

}







- (IBAction)bth3pressed:(UIButton *)sender
{
    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"登入" message:@"请输入用户名密码" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
    alertView.alertViewStyle =  UIAlertViewStyleLoginAndPasswordInput;
    [alertView show];

}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    NSLog(@"用户点了第几个按钮 = %i,按钮的文字信息:%@",buttonIndex+1,[alertView buttonTitleAtIndex:buttonIndex]);
    NSLog(@"弹窗的信息:%@",alertView.title);
    
    if([alertView.title isEqualToString:@"登入"])
    {
        NSString *info = [NSString stringWithFormat:@"用户名:%@ 密码:%@",[alertView textFieldAtIndex:0].text,[alertView textFieldAtIndex:1].text];
        self.infoLabel.text = info;
    }
}


#pragma mark - 弹出操作表 (UIActionSheet)
- (IBAction)bth4pressed:(UIButton *)sender
{
    UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"小明 一起上吃饭吧" delegate:self cancelButtonTitle:@"我吃过了，你去吧" destructiveButtonTitle:@"好的，一起去" otherButtonTitles:@"一起吃点什么",@"随便吧", nil];
    [sheet showInView:self.view];
}













@end
